<?php
namespace app\exam\controller;

use app\exam\model\ExamModel;
class Exam extends Common
{
	/*
        获取考试列表
        method: POST
        params:

    */
    public function examList(){
        if($this->_method != 'post'){
            $res = array(
                'code' => '0001'
            );
            $this->_response($res);
        }
        $ExamModel = new ExamModel();
        $ret = $ExamModel->getExamList();

        if($ret === false){
            $res = array(
                'code' => '0003'
            );
        }elseif(empty($ret['code']) == false){
            $res = $ret;
        }else{
            $res = array(
                'code' => '0',
                'data' => $ret
            );
        }

        $this->_response($res);
    }

    /*
        获取考试信息
        params:
            token 用户token
    */
    public function getCandidateExamInfo()
    {
        if($this->_method != 'post'){
            $res = array(
                'code' => '0001'
            );
            $this->_response($res);
        }

        $this->_checkToken();

        $ExamModel = new ExamModel();
        $ret = $ExamModel->getCandidateExamInfo($this->args['token']);

        if($ret === false){
            $res = array(
                'code' => '0003'
            );
        }elseif(empty($ret['code']) == false){
            $res = $ret;
        }else{
            $res = array(
                'code' => '0',
                'data' => $ret
            );
        }

        $this->_response($res);
    }
}
